import java.util.Scanner;

public class CaraSello {
	public static void main(String[] args) {

		Scanner intro = new Scanner(System.in);
		int john = 0, mary = 0, numJuegos, ri;

		while (true) {

			numJuegos = intro.nextInt();

			if (numJuegos == 0) {
				break;
			} else if (numJuegos >= 1 && numJuegos <= 10000) {
				john = 0;
				mary = 0;
				for (int i = 0; i < numJuegos; i++) {
					ri = intro.nextInt();
					if (ri == 1) {
						john++;
					} else {
						mary++;
					}
				}
			} else {
				System.out.println("Vuelve a ingresar un numero");
			}
		}
		System.out.println("Mary won " + mary + " times and John won " + john
				+ " times");
	}
}
